package com.sky.web;

import com.sky.domain.PmsCategory;
import com.sky.service.PmsCategoryService;
import com.sky.vo.web.CateLog2VO;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class IndexController {

    @Resource
    private PmsCategoryService pmsCategoryService;

    @GetMapping({"/","index"})
    public String indexPage(Model model, HttpServletRequest request) {
        List<PmsCategory> pmsCategoryList = pmsCategoryService.getCategoryTopLevel();
        model.addAttribute("categorys", pmsCategoryList);
        return "index";
    }

    @GetMapping("/index/catalog.json")
    @ResponseBody
    public Map<String,List<CateLog2VO>> getCatalogJson() {
        Map<String,List<CateLog2VO>> map = pmsCategoryService.getCatalogJson();
        return map;
    }
}
